﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace BOL
{
    public class Comment
    {
        public static Comment Instance = new Comment();

        public string getCommnet1(string table, int product_id, string column)
        {
            string comment = "";
            DataTable dt = DAL.DCollector.DBCollector.Instance.StoredSelectAllTableWhereIDOrderBySort(table, "Comment1_Active","1","Comment_Date","Desc");
            DataView dv = dt.DefaultView;
            dv.RowFilter = "Product_ID =" + product_id;
            DataTable temp = dv.ToTable();            
            for (int i = 0; i < temp.Rows.Count; i++)
            {
                comment += "<div class=\"comment-list\"><div class=\"comment-item\">";
                comment += "<div class=\"avatar\"><img src=\"" + temp.Rows[i]["Comment1_Avatar"] + "\" /></div>";



                comment += "<div class=\"user-detail\">";
                comment += "<span><strong>" + temp.Rows[i]["Comment1_Name"] + "</strong></span><span class=\"timeago\">" + temp.Rows[i]["Comment1_Date"] + "</span>";
                comment += "<div class=\"clearfix\"></div>";
                comment += "<p>" + temp.Rows[i]["Comment1_Details"] + "</p></div>";

                comment += "<div style=\"display:block\" class=\"clearfix\"></div>";
                comment += "<div class=\"reply\" align=\"right\" style=\"padding: 0px 10px 5px 0px;\">";
                comment += "</div><div class=\"show-comment\"><div id=\"" + (i) + "\" class=\"show\">";
                comment += "<textarea class=\"txtShow-Comment\" placeholder=\"Viết bình luận tại đây...\"></textarea>";
                comment += "<span><input type=\"submit\" runat=\"server\" class=\"btnShow-Comment\" name=\"btnCommentb2\" id=\"btnCommentb2\" ClientIdMode=\"static\" onclick=\"btnCommentb2_Click\"/>";
                comment += "<span><a href=\"javascript:void(0)\" class=\"btnShow-Comment\"></a>";
                comment += "<a href=\"javascript:void(0)\" onclick=\"$('#" + (i) + "').addClass('show');\">(X)Đóng lại</a></span></div></div>";

               // comment += getComment2("tbl_Comment2", Convert.ToInt32(temp.Rows[i]["Comment1_ID"].ToString()), "*");

                comment += "</div></div>";
            }

            return comment;

        }

        public string getComment2(string table, int comment_id, string column)
        {
            string comment2 = "";
            DataTable dt = DAL.DCollector.DBCollector.Instance.StoredSelectAllTableWhereIDOrderBySort(table, "Comment1_Active", "1", "Comment_Date", "Desc");
            DataView dv = dt.DefaultView;
            dv.RowFilter = "Comment1_ID =" + comment_id;
            DataTable temp = dv.ToTable();
            //comment2 += "<div class=\"comment-list-item\">";
            for (int i = 0; i < temp.Rows.Count; i++)
            {

                comment2 += "<div class=\"comment-comment\"><div style=\"float: right; width: 90%;\">";

                comment2 += "<div class=\"avatar\"><img src=\"" + temp.Rows[i]["Comment2_Avatar"] + "\" /></div>";

                comment2 += "<div class=\"user-detail\"><span><strong>" + temp.Rows[i]["Comment2_Name"] + "</strong></span><span class=\"timeago\">" + temp.Rows[i]["Comment2_Date"] + "</span>";
                comment2 += "</div><p>" + temp.Rows[i]["Comment2_Details"] + "</p></div>";
                comment2 += "</div>";

            }
            //comment2 += "</div>";
            return comment2;

        }
    }
}

